#动态参数
# v1 = "我叫{},今年{},性别{}".format("小峰",18,"男")
# v2 = "我叫{name},今年{age},性别{gender}".format(name="小峰",age=18,gender="男")
# print(v1)
# print(v2)

# # 1. ** 必须放在 * 的后面
# def func1(*args, **kwargs):
#     print(args, kwargs)
# func1(1,2,name='John')
# # 2. 参数和动态参数混合时，动态参数只能放在最后。
# def func2(a1, a2, a3, *args, **kwargs):
#     print(a1, a2, a3, args, kwargs)
# func2(1,2,4,6,name='John',a=2,b=3,c=4)
# # 3. 默认值参数和动态参数同时存在
# def func3(a1, a2, a3, a4=10, *args, a5=20, **kwargs):
#     print(a1, a2, a3, a4, a5, args, kwargs)
#
# func3(11, 22, 33, 44, 55, 66, 77, a5=10, a10=123)


#形参固定，实参用* 和 **
# def func(a1, a2):
#     print(a1, a2)
#
# func(11, 22)
# func(a1=1, a2=2)
# func(*[11, 22])
# func(**{"a1": 11, "a2": 22})
#

#形参用*和**，实参也用*和**
# def func(*args, **kwargs):
#     print(args, kwargs)
#
#
# func(11, 22)
# func(11, 22, name="小峰", age=18)
#
# # 小坑，([11,22,33], {"k1":1,"k2":2}), {}
# func([11, 22, 33], {"k1": 1, "k2": 2})
#
# # args=(11,22,33),kwargs={"k1":1,"k2":2}
# func(*[11, 22, 33], **{"k1": 1, "k2": 2})
# # 值得注意：按照这个方式将数据传递给args和kwargs时，数据是会重新拷贝一份的
# # （可理解为内部循环每个元素并设置到args和kwargs中）。


v3 = "我是{},年龄：{}。".format(*["小峰",18])
v4 = "我是{name},年龄：{age}。".format(**{"name":"小峰","age":18})
print(v3)
print(v4)
